/*
 * @lc app=leetcode.cn id=559 lang=cpp
 *
 * [559] N 叉树的最大深度
 */

// @lc code=start
/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
    int maxDepth(Node* root, int height)
    {
        if(root == nullptr) return height - 1;
        int ans = height;
        for(auto v : root->children)
        {
            ans = std::max(ans, maxDepth(v, height + 1));
        }
        return ans;
    }
public:
    int maxDepth(Node* root) {
        return maxDepth(root, 1);
    }
};
// @lc code=end

